<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/Static/Css/reset.css" />
<link rel="stylesheet" type="text/css" href="/Static/Css/zh-cn-system.css" />
<link rel="stylesheet" type="text/css" href="/Static/Css/table_form.css" />
<script src="/Public/js/jquery.min.js"></script>
<script src="/Public/js/jquery.form.js"></script>
<script src="/Public/js/main.js"></script>
<script type="text/javascript" src="/Public/artDialog/jquery.artDialog.js?skin=default"></script>
<script type="text/javascript" src="/Public/artDialog/plugins/iframeTools.js"></script>
</head>
<body>

<div class="subnav">
  <div class="explain-col" style="position: relative;">
    <form name="searchForm" id="searchForm" method="GET" action="/index.php/area/index">
      <input name="pid" type="hidden" value="<?php echo ($_GET['pid']); ?>">
      <input name="cid" type="hidden" value="<?php echo ($_GET['cid']); ?>">
      选择类别：
      <select name="selectId" id="selectId">
        <option value="0">请选择分类</option>
        <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>" ><?php echo ($vo["name"]); ?> </option><?php endforeach; endif; else: echo "" ;endif; ?>
      </select>
    </form>
    <div class="content-menu" style="position: absolute; right: 30px;top: 5px;"> <a href="javascript:history.go(-1);" class="add fb"><em>返回</em></a> </div>
  </div>
</div>
<!--subnav-->
<div class="pad-lr-10">
  <form id="listForm" action="/index.php/area/updateSort" method="POST">
    <div class="table-list">
      <table width="100%" cellspacing="0">
        <thead>
          <tr>
            <th align="center" width="50">排序</th>
            <th align="center" width="50">序号</th>
            <th align="center" width="50">ID</th>
            <th align="left">名称
            <?php if(!empty($_GET['pName'])): ?><span class="red">(<?php echo ($_GET['pName']); ?>)</span><?php endif; ?>
            </th>
            <th align="center" width="80">编号</th>
            <th align="center" width="80">级别</th>
            <th align="center"  width="80">状态</th>
            <th align="center" width="180">管理操作</th>
          </tr>
        </thead>
        <tbody id="list">
          <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr id="list_<?php echo ($vo["id"]); ?>">
              <td align="center">
              	<input name='sortArr[]' type='text' size="4" value='<?php echo ($vo["sort"]); ?>' class='input-text-c'>
              	 <input name='idArr[]' type="hidden" value='<?php echo ($vo["id"]); ?>'>
              </td>
              <td align="center"><?php echo ($i); ?></td>
              <td align="center"><?php echo ($vo["id"]); ?></td>
              <td align="left"><?php echo ($vo["name"]); ?></td>
              <td align="center"><?php echo ($vo["bh"]); ?></td>
              <td align="center"><?php echo ($vo["levelName"]); ?></td>
              <td align="center"><a href="javascript:changeStatus(<?php echo ($vo["id"]); ?>);" id="status-<?php echo ($vo["id"]); ?>" name="<?php echo ($vo["status"]); ?>" title="" class="status" ><?php echo ($vo["statusName"]); ?></a></td>
              <td align="center"><a href="/index.php/area/index/pid/<?php echo ($vo["id"]); ?>/pName/<?php echo ($vo["name"]); ?>" class="showCityList">【查看城市列表】</a> <a href="/index.php/area/index/pid/<?php echo ($_GET['pid']); ?>/cid/<?php echo ($vo["id"]); ?>/pName/<?php echo ($vo["name"]); ?>" class="showAreaList">【查看区域列表】</a></td>
            </tr><?php endforeach; endif; else: echo "" ;endif; ?>
        </tbody>
      </table>
      <div class="btn">
        <div id="pages"><?php echo ($page); ?></div>
        <input name="submit" type="submit" class="button" value="更新排序" >
      </div>
    </div>
  </form>
</div>
</body></html><script type="text/javascript">
$(document).ready(function(){
	//赋予状态颜色
	$(".status").each(function(i, val) {
        var status = $(this).attr('name');
		if(status==1){
			$(this).addClass('blue');
		}else{
			$(this).addClass('red');
		}
    });
	
	//隐藏区域列表按钮
	$(".showAreaList").hide();
	$(".content-menu").hide();
	if( "<?php echo ($_GET['pid']); ?>"!=0 ){
		$(".showAreaList").show();
		$(".showCityList").hide();
		$(".content-menu").show();
	}
	if( "<?php echo ($_GET['pid']); ?>"!=0 && "<?php echo ($_GET['cid']); ?>"!=0 ){
		$(".showAreaList").hide();
		$(".showCityList").hide();
		$(".content-menu").show();
	}
	
    $('#listForm').ajaxForm({
		beforeSubmit:  checkForm,
		success:       complete,
		dataType: 'json'
	});
	function checkForm(){
		return true;
	}
	
	var origin = $.artDialog.open.origin;
    function complete(data){
		msg(data.info,data.status);
		if(data.status)  setTimeout(function(){origin.location.reload();},1000);
		closeWin(1500);
    }
	
	$("#selectId").change(function(){
		var  pid = $("input[name='pid']").val();
		var  cid = $("input[name='cid']").val();
		var selectId = $(this).val();
		if(pid==0 || pid==''){
			$("input[name='pid']").val(selectId);
		}else{
			$("input[name='cid']").val(selectId);
		}
		
		$("#searchForm").submit();
	})
	
})

function changeStatus(id){
	var statusId = $("#status-"+id).attr('name');
	$.get("/index.php/area/changeStatus/id/"+id+"/statusId/"+statusId, function(data) {
	if(statusId==1){
			$("#status-"+id).text('隐藏');
			$("#status-"+id).attr('name',0);
			$("#status-"+id).attr('class','red');
		}else{
			$("#status-"+id).text('显示');
			$("#status-"+id).attr('name',1);
			$("#status-"+id).attr('class','blue');
		}				  
	});
}

</script>